﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Components.Helpers;
using ASPNETVN.PORTAL.Components.Configuration;
using ASPNETVN.PORTAL.Components.Configuration.Settings;
using ASPNETVN.PORTAL.Components.UI.DataTypes;

namespace ASPNETVN.PORTAL.Modules.SCHEDULE
{
    public enum ModulePages
    {
        Item,
        AddEditItem,
        Detail
    }
    public partial class Main : PortalModuleControl
    {
        public Main()
        {
            // Define an Array List
            ArrayList list1 = new ArrayList();

            // Sắp xếp theo cột.
            list1.Add(new ListItem("10 records per a page", "10"));
            list1.Add(new ListItem("20 records per a page", "20"));
            list1.Add(new ListItem("50 records per a page", "50"));
            list1.Add(new ListItem("100 records per a page", "100"));

            ModuleSettingItem pageSizeSetting = new ModuleSettingItem(new CustomListDataType(list1, "Text", "Value"));
            pageSizeSetting.Name = "Page Size";
            pageSizeSetting.Value = "10";
            pageSizeSetting.Description = "Page Size";
            pageSizeSetting.SortOrder = 1;
            this.BaseSettings.Add("PageSize", pageSizeSetting);
           
        }
        private void LoadModulePage()
        {
            const string basePath = "~/Modules/ASPNETVN.PORTAL.Modules.SCHEDULE/";
            const string pageQuery = "page";
            string pageName = Request.QueryString[pageQuery];

            ModulePages page;
            if (pageName == null)
            {
                page = ModulePages.Item;
            }
            else
            {
                page = (ModulePages)Enum.Parse(typeof(ModulePages), Request.QueryString[pageQuery], true);
            }

            string src = string.Format("{0}Controls/{1}.ascx", basePath, page);
            ModulePage ctl = (ModulePage)this.LoadControl(src);
            ctl.ParentControl = this;
            this.divContent.Controls.Add(ctl);
        }
        //-----------------------------------------------------------------------------------------

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            //hlSendQuestion.NavigateUrl = HttpUrlBuilder.BuildAddEditUrl(this.ModuleID, 0, "AddItem");
            //hlMonitor.NavigateUrl = HttpUrlBuilder.BuildAddEditUrl(this.ModuleID, 0, "Monitor");
        }

        //-----------------------------------------------------------------------------------------

        protected void Page_Load(object sender, EventArgs e)
        {
            this.LoadModulePage();
            this.ModuleTitle.AddUrl = HttpUrlBuilder.BuildAddEditUrl(this.ModuleID, 0, "AddEditItem", "");
        }
           
    }
}